<?php
	include ("controller.php");

	define('MODEL_NAME','models/admin/');
	
	//设置数据库
	$db  = new DBSQL($DB_Config);
	
	//设置数据库
	$tpl = new template($tpl_set);					//设置模板目录
	
	
	//释放系统设置
	@extract(sys_config());
	
	
	
	
	//后台检测登陆
	$sys_us = $_SESSION['_sys_user'];
	if (!trim($sys_us['username'])){
		include MODEL_NAME."login.php";
	}
	
	
	//安全退出
	if($model=='exit'){
		unset($_SESSION['_sys_user']);
		msg('恭喜，您已经安全退出本系统！',$sys_page,3);
	}
	
	
	
	//自动引入自动table模块
	if ($model!='' && is_file('./tables/'.$model.'.php')){
		include './tables/'.$model.'.php';
		$newmode = ucfirst($model);
		$name = 'o'.$newmode;
		$$name = new $newmode($db);
	}
	
	//静态文件模块
	include './tables/html.php';
	$oHtml	= new Html($db);
	
	//系统管理菜单
	$menu = new Menu;
	include'./config/default_menu.php';
	
	
	//模块检测
	$model = trim($model);
	$model = ($model=='')?'default':$model;
	
	//载入模块
		if(trim($action)!=''){
			//常规action命令
			if(is_file(MODEL_NAME.$model.'_'.$action.'.php')){
				include (MODEL_NAME.$model.'_'.$action.'.php');
			}else{
				error();
			}
		}else{
			if(is_file(MODEL_NAME.$model.'.php')){
				include (MODEL_NAME.$model.'.php');
			}
		}
	
	
	//框架标题处理页面
	$tpl->set_file('sys_frame_title');
	$ftitle = $tpl->r();
	
	//系统菜单
	$gAction = $action;
	$gModel = $model;
	$fmenu = $menu->disMenu($menu_list);
	
	//框架 frame
	$tpl->set_file('sys_frame');
	$tpl->p();
	echo $tpl->inc_list();
?>